<template>
  <!-- APP根组件 -->
  <div id="app">
    <!-- 路由占位符 -->
    <router-view></router-view>
  </div>
</template>

<style>
</style>

<script>
export default {
  name: "app",
  beforeCreate() {
    var isRefresh = this.$router.options.routes.find((route) => {
      return route.path === this.$router.currentRoute.path;
    });
    //当访问页面不为初始路由页面、404页面
    if (!isRefresh && this.$router.currentRoute.path !== "/404") {
      // 防止重复配置相同路由
      if (this.$router.options.routes.length <= 1) {
        //全屏loading
        const loading = this.$loading({
          lock: true,
          text: "基础数据载入中......",
          spinner: "el-icon-loading",
          background: "rgba(96, 96, 96, 96)",
        });
        //数据重载
        this.$store.dispatch("DataReload").then((res) => { loading.close();})
          .catch(() => {
            loading.close();
            this.$loading({
              lock: true,
              text: "基础数据载入失败！",
              spinner: "el-icon-error",
              background: "rgba(96, 96, 96, 96)",
            });
          });
      }
    }
  },
};
</script>